var  clickState = true;
$(function(){
	$("#save-button").click(function(){
		var refundId=init.refundId;
		if(refundId.length==0){
			layer.msg("售后单不存在！");
			return false;
		}
		
		var totalJe = $("#refundJe").attr("data-totalJe");
		var money = $("#refundJe").val();
		if(!ismoney(money)){
			$("#refundJe").val("");
			$("#refundJe").focus();
			layer.msg("请输入正确的退款金额（精确到两位小数）");
			return false;
		}else if((Number(totalJe)-Number(money))<0){
			$("#refundJe").val("");
			$("#refundJe").focus();
			layer.msg("退款金额不能大于可退款金额");
			return false;
			
		}
		
		var refundData ={
			"refundId":refundId,
			"money":money
		}
		if(clickState){
			clickState = false;
			$.ajax({
				url:basePath+"/refund/saveRefundMoney.shtml",
				data:refundData,
				type:"post",
				dataType:"JSON",
				success:ajaxSuccessCloseFun
			});
		}
	});
	$("#close-button").click(function(){
		parent.closeLayer(0);
	});
	$("#refundJe").keyup(function(){
		var totalJe = $(this).attr("data-totalJe");
		var money = $(this).val();
		var str="";
		if(!ismoney(money)){
			str="请输入正确的退款金额（精确到两位小数）";
			$(this).val("");
			$(this).focus();
		}else if((Number(totalJe)-Number(money))<0){
			str="退款金额不能大于可退款金额";
			$(this).val("");
			$(this).focus();
		}
		$(".remind-text").html(str);
		
	});
});
